package com.kantboot.business.shop.web.admin.controller;

import com.kantboot.business.shop.domain.vo.BusShopGoodsTypeHasChildren;
import com.kantboot.global.data.change.annotaion.DataChange;
import com.kantboot.global.data.change.common.CommonDataChangeKey;
import com.kantboot.util.common.result.RestResult;
import com.kantboot.util.core.controller.BaseAdminController;
import com.kantboot.util.core.redis.RedisUtil;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 商品类型控制器
 */
@RestController
@RequestMapping("/business-shop-web/admin/shopGoodsTypeHasChildren")
public class BusShopGoodsTypeControllerHasChildrenOfAdmin extends BaseAdminController<BusShopGoodsTypeHasChildren,Long> {

    @Resource
    private RedisUtil redisUtil;

    @DataChange(key = CommonDataChangeKey.CLIENT_INIT)
    @RequestMapping(value = "/save")
    @Override
    public RestResult<Object> save(@RequestBody BusShopGoodsTypeHasChildren busShopGoodsType) {
        redisUtil.deleteByPrefix("goodsTypeI18n:");
        return super.save(busShopGoodsType);
    }

    @DataChange(key = CommonDataChangeKey.CLIENT_INIT)
    @RequestMapping(value = "/remove")
    @Override
    public RestResult<BusShopGoodsTypeHasChildren> remove(BusShopGoodsTypeHasChildren busShopGoodsTypeHasChildren) {
        redisUtil.deleteByPrefix("goodsTypeI18n:");
        return super.remove(busShopGoodsTypeHasChildren);
    }

}
